// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2008-3-21 9:20:23
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   Im.java

package org.water.garden.db;

import android.content.*;
import android.database.Cursor;
import android.net.Uri;
import android.os.Handler;
import android.provider.BaseColumns;

import java.util.HashMap;

// Referenced classes of package android.provider:
//            BaseColumns

public class Im
{
    public static final class OutgoingRmq
        implements BaseColumns, OutgoingRmqColumn
    {

        public static final Uri CONTENT_URI = Uri.parse("content://im/outgoingRmqMessages");
        public static final String DEFAULT_SORT_ORDER = "rmq_id ASC";


        public OutgoingRmq()
        {
        }
    }

    public static interface OutgoingRmqColumn
    {

        public static final String RMQ_ID = "rmq_id";
        public static final String TYPE = "type";
        public static final String TIMESTAMP = "ts";
        public static final String DATA = "data";
    }

    public static final class GTalkDataMessageCapable
        implements BaseColumns, GTalkDataMessageCapableColumn
    {

        public static final Uri CONTENT_URI = Uri.parse("content://im/gtalkDataMessageCapable");
        public static final String DEFAULT_SORT_ORDER = "bare_jid ASC";


        public GTalkDataMessageCapable()
        {
        }
    }

    public static interface GTalkDataMessageCapableColumn
    {

        public static final String BARE_JID = "bare_jid";
        public static final String RESOURCE = "resource";
        public static final String CAPABILITY_VERSION = "cap_version";
    }

    public static class Settings
        implements SettingsColumns
    {
        public static class QueryMap extends ContentQueryMap
        {

            public void setAutomaticallyConnectToGTalkServer(boolean autoConnect)
            {
                Settings.setAutomaticallyConnectGTalk(mContentResolver, autoConnect);
            }

            public boolean getAutomaticallyConnectToGTalkServer()
            {
                return getBoolean("gtalk_auto_connect", true);
            }

            public void setAutomaticallyStartService(boolean autostartService)
            {
                Settings.setAutomaticallyStartService(mContentResolver, autostartService);
            }

            public boolean getAutomaticallyStartService()
            {
                return getBoolean("auto_start_service", true);
            }

            public void setHideOfflineContacts(boolean hideOfflineContacts)
            {
                Settings.setHideOfflineContacts(mContentResolver, hideOfflineContacts);
            }

            public boolean getHideOfflineContacts()
            {
                return getBoolean("hide_offline_contacts", false);
            }

            public void setEnableNotification(boolean enable)
            {
                Settings.setEnableNotification(mContentResolver, enable);
            }

            public boolean getEnableNotification()
            {
                return getBoolean("enable_notification", true);
            }

            public void setRingerMode(int mode)
            {
                Settings.setRingerMode(mContentResolver, mode);
            }

            public int getRingerMode()
            {
                return getInteger("ringer_mode", 2);
            }

            public void setRingtoneURI(String ringtoneUri)
            {
                Settings.setRingtoneURI(mContentResolver, ringtoneUri);
            }

            public String getRingtoneURI()
            {
                return getString("ringtone", null);
            }

            private boolean getBoolean(String name, boolean def)
            {
                ContentValues values = getValues(name);
                return values == null ? def : values.getAsBoolean("value").booleanValue();
            }

            private String getString(String name, String def)
            {
                ContentValues values = getValues(name);
                return values == null ? def : values.getAsString("value");
            }

            private int getInteger(String name, int def)
            {
                ContentValues values = getValues(name);
                return values == null ? def : values.getAsInteger("value").intValue();
            }

            private long getLong(String name, long def)
            {
                ContentValues values = getValues(name);
                return values == null ? def : values.getAsLong("value").longValue();
            }

            private ContentResolver mContentResolver;

            public QueryMap(ContentResolver contentResolver, boolean keepUpdated, Handler handlerForUpdateNotifications)
            {
                super(contentResolver.query(Settings.CONTENT_URI, null, null, null, null), "name", keepUpdated, handlerForUpdateNotifications);
                mContentResolver = contentResolver;
            }
        }


        private static void putBoolean(ContentResolver contentResolver, String name, boolean val)
        {
            ContentValues values = new ContentValues();
            values.put("name", name);
            values.put("value", Boolean.toString(val));
            contentResolver.insert(CONTENT_URI, values);
        }

        private static void putInteger(ContentResolver contentResolver, String name, int val)
        {
            ContentValues values = new ContentValues();
            values.put("name", name);
            values.put("value", Integer.toString(val));
            contentResolver.insert(CONTENT_URI, values);
        }

        private static void putLong(ContentResolver contentResolver, String name, long val)
        {
            ContentValues values = new ContentValues();
            values.put("name", name);
            values.put("value", Long.toString(val));
            contentResolver.insert(CONTENT_URI, values);
        }

        private static void putString(ContentResolver contentResolver, String name, String val)
        {
            ContentValues values = new ContentValues();
            values.put("name", name);
            values.put("value", val);
            contentResolver.insert(CONTENT_URI, values);
        }

        public static void setAutomaticallyConnectGTalk(ContentResolver contentResolver, boolean autoConnect)
        {
            putBoolean(contentResolver, "gtalk_auto_connect", autoConnect);
        }

        public static void setAutomaticallyStartService(ContentResolver contentResolver, boolean autostartService)
        {
            putBoolean(contentResolver, "auto_start_service", autostartService);
        }

        public static void setHideOfflineContacts(ContentResolver contentResolver, boolean hideOfflineContacts)
        {
            putBoolean(contentResolver, "hide_offline_contacts", hideOfflineContacts);
        }

        public static void setEnableNotification(ContentResolver contentResolver, boolean enable)
        {
            putBoolean(contentResolver, "enable_notification", enable);
        }

        public static void setRingerMode(ContentResolver contentResolver, int mode)
        {
            putInteger(contentResolver, "ringer_mode", mode);
        }

        public static void setRingtoneURI(ContentResolver contentResolver, String ringtoneUri)
        {
            putString(contentResolver, "ringtone", ringtoneUri);
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/settings");
        public static final String CONTENT_TYPE = "vnd.android-dir/im-settings";
        public static final String SETTING_AUTOMATICALLY_CONNECT_GTALK = "gtalk_auto_connect";
        public static final String SETTING_AUTOMATICALLY_START_SERVICE = "auto_start_service";
        public static final String SETTING_HIDE_OFFLINE_CONTACTS = "hide_offline_contacts";
        public static final String SETTING_ENABLE_NOTIFICATION = "enable_notification";
        public static final String SETTING_RINGER_MODE = "ringer_mode";
        public static final String SETTING_RINGTONE = "ringtone";
        public static final String LAST_RMQ_RECEIVED = "last_rmq_rec";


        private Settings()
        {
        }
    }

    public static interface SettingsColumns
    {

        public static final String NAME = "name";
        public static final String VALUE = "value";
    }

    public static class ProviderSettings
        implements ProviderSettingsColumns
    {

        public static HashMap queryProviderSettings(ContentResolver cr, long providerId)
        {
            HashMap settings = new HashMap();
            String projection[] = {
                "name", "value"
            };
            Cursor c = cr.query(ContentUris.withAppendedId(CONTENT_URI, providerId), projection, null, null, null);
            if(c == null)
                return null;
            for(; c.next(); settings.put(c.getString(0), c.getString(1)));
            c.close();
            return settings;
        }

        public static String getStringValue(ContentResolver cr, long providerId, String settingName)
        {
            String ret = null;
            Cursor c = getSettingValue(cr, providerId, settingName);
            if(c != null)
            {
                ret = c.getString(0);
                c.close();
            }
            return ret;
        }

        public static boolean getBooleanValue(ContentResolver cr, long providerId, String settingName)
        {
            boolean ret = false;
            Cursor c = getSettingValue(cr, providerId, settingName);
            if(c != null)
            {
                ret = c.getInt(0) != 0;
                c.close();
            }
            return ret;
        }

        private static Cursor getSettingValue(ContentResolver cr, long providerId, String settingName)
        {
            Cursor c = cr.query(ContentUris.withAppendedId(CONTENT_URI, providerId), new String[] {
                "value"
            }, "name=?", new String[] {
                settingName
            }, null);
            if(c != null && !c.first())
            {
                c.close();
                return null;
            } else
            {
                return c;
            }
        }

        public static void putLongValue(ContentResolver cr, long providerId, String name, long value)
        {
            ContentValues v = new ContentValues(3);
            v.put("provider", Long.valueOf(providerId));
            v.put("name", name);
            v.put("value", Long.valueOf(value));
            cr.insert(CONTENT_URI, v);
        }

        public static void putBooleanValue(ContentResolver cr, long providerId, String name, boolean value)
        {
            ContentValues v = new ContentValues(3);
            v.put("provider", Long.valueOf(providerId));
            v.put("name", name);
            v.put("value", Boolean.valueOf(value));
            cr.insert(CONTENT_URI, v);
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/providerSettings");
        public static final String CONTENT_TYPE = "vnd.android-dir/im-providerSettings";
        public static final String SHOW_OFFLINE_CONTACTS = "show_offline_contacts";
        public static final String DEFAULT_ACCOUNT = "default_account";
        public static final String IMPS_DATA_CHANNEL_PREF = "imps_data_channel";
        public static final String IMPS_DATA_ENCODING_PREF = "imps_data_encoding";
        public static final String IMPS_CIR_CHANNEL_PREF = "imps_cir_channel";
        public static final String IMPS_HOST_PREF = "imps_host";
        public static final String IMPS_CLIENT_ID_PREF = "imps_client_id";
        public static final String IMPS_MSISDN_PREF = "imps_msisdn";
        public static final String IMPS_SECURE_LOGIN_PREF = "imps_secure_login";
        public static final String IMPS_BASIC_PA_ONLY_PREF = "imps_basic_pa_only";


        private ProviderSettings()
        {
        }
    }

    public static interface ProviderSettingsColumns
    {

        public static final String PROVIDER = "provider";
        public static final String NAME = "name";
        public static final String VALUE = "value";
    }

    public static class SessionCookies
        implements SessionCookiesColumns, BaseColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, null);
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy);
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/sessionCookies");
        public static final Uri CONTENT_URI_SESSION_COOKIES_BY = Uri.parse("content://im/sessionCookiesBy");
        public static final String CONTENT_TYPE = "vnd.android-dir/im-sessionCookies";


        private SessionCookies()
        {
        }
    }

    public static interface SessionCookiesColumns
    {

        public static final String NAME = "name";
        public static final String VALUE = "value";
        public static final String PROVIDER = "provider";
        public static final String ACCOUNT = "account";
    }

    public static final class Chats
        implements BaseColumns, ChatsColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "last_message_date ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "last_message_date ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/chats");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-chats";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-chats";
        public static final String DEFAULT_SORT_ORDER = "last_message_date ASC";


        private Chats()
        {
        }
    }

    public static interface ChatsColumns
    {

        public static final String CONTACT_ID = "contact_id";
        public static final String JID_RESOURCE = "jid_resource";
        public static final String GROUP_CHAT = "groupchat";
        public static final String LAST_UNREAD_MESSAGE = "last_unread_message";
        public static final String LAST_MESSAGE_DATE = "last_message_date";
    }

    public static final class Presence
        implements BaseColumns, PresenceColumns
    {

        public static final Uri CONTENT_URI = Uri.parse("content://im/presence");
        public static final String DEFAULT_SORT_ORDER = "mode DESC";


        public Presence()
        {
        }
    }

    public static interface PresenceColumns
    {

        public static final String CONTACT_ID = "contact_id";
        public static final String PRIORITY = "priority";
        public static final String PRESENCE_STATUS = "mode";
        public static final int OFFLINE = 0;
        public static final int INVISIBLE = 1;
        public static final int DO_NOT_DISTURB = 2;
        public static final int AWAY = 3;
        public static final int IDLE = 4;
        public static final int AVAILABLE = 5;
        public static final String PRESENCE_CUSTOM_STATUS = "status";
    }

    public static final class Subscriptions
        implements BaseColumns, SubscriptionsColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "username ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "username ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/subscriptions");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-subscriptions";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-subscriptions";
        public static final String DEFAULT_SORT_ORDER = "username ASC";


        private Subscriptions()
        {
        }
    }

    public static interface SubscriptionsColumns
    {

        public static final String PROVIDER = "providerId";
        public static final String ACCOUNT = "accountId";
        public static final String USERNAME = "username";
    }

    public static final class Avatars
        implements BaseColumns, AvatarsColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "contact ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "contact ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/avatars");
        public static final Uri CONTENT_URI_AVATARS_BY = Uri.parse("content://im/avatarsBy");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-avatars";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-avatars";
        public static final String DEFAULT_SORT_ORDER = "contact ASC";


        private Avatars()
        {
        }
    }

    public static interface AvatarsColumns
    {

        public static final String CONTACT = "contact";
        public static final String PROVIDER = "provider";
        public static final String ACCOUNT = "account";
        public static final String HASH = "hash";
        public static final String DATA = "_data";
    }

    public static final class GroupMessages
        implements BaseColumns, GroupMessageColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "date ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "date ASC");
        }

        public static final Uri getContentUriByGroup(long groupId)
        {
            android.net.Uri.Builder builder = CONTENT_URI_GROUP_MESSAGES_BY.buildUpon();
            ContentUris.appendId(builder, groupId);
            return builder.build();
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/groupMessages");
        public static final Uri CONTENT_URI_GROUP_MESSAGES_BY = Uri.parse("content://im/groupMessagesBy");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-groupMessages";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-groupMessages";
        public static final String DEFAULT_SORT_ORDER = "date ASC";


        private GroupMessages()
        {
        }
    }

    public static interface GroupMessageColumns
        extends BaseMessageColumns
    {

        public static final String GROUP = "groupId";
    }

    public static final class Invitation
        implements InvitationColumns, BaseColumns
    {

        public static final Uri CONTENT_URI = Uri.parse("content://im/invitations");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-invitations";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-invitations";


        private Invitation()
        {
        }
    }

    public static interface InvitationColumns
    {

        public static final String PROVIDER = "providerId";
        public static final String ACCOUNT = "accountId";
        public static final String INVITE_ID = "inviteId";
        public static final String SENDER = "sender";
        public static final String GROUP_NAME = "groupName";
        public static final String NOTE = "note";
        public static final String STATUS = "status";
        public static final int STATUS_PENDING = 0;
        public static final int STATUS_ACCEPTED = 1;
        public static final int STATUS_REJECTED = 2;
    }

    public static final class GroupMembers
        implements GroupMemberColumns
    {

        public static final Uri CONTENT_URI = Uri.parse("content://im/groupMembers");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-groupMembers";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-groupMembers";


        private GroupMembers()
        {
        }
    }

    public static interface GroupMemberColumns
    {

        public static final String GROUP = "groupId";
        public static final String USERNAME = "username";
        public static final String NICKNAME = "nickname";
    }

    public static final class Messages
        implements BaseColumns, MessagesColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "date ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "date ASC");
        }

        public static final Uri getContentUriByContact(long providerId, long accountId, String username)
        {
            android.net.Uri.Builder builder = CONTENT_URI_MESSAGES_BY.buildUpon();
            ContentUris.appendId(builder, providerId);
            ContentUris.appendId(builder, accountId);
            builder.appendPath(username);
            return builder.build();
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/messages");
        public static final Uri CONTENT_URI_MESSAGES_BY = Uri.parse("content://im/messagesBy");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-messages";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-messages";
        public static final String DEFAULT_SORT_ORDER = "date ASC";


        private Messages()
        {
        }
    }

    public static interface MessagesColumns
        extends BaseMessageColumns
    {

        public static final String PROVIDER = "provider";
        public static final String ACCOUNT = "account";
    }

    public static interface BaseMessageColumns
    {

        public static final String CONTACT = "contact";
        public static final String BODY = "body";
        public static final String DATE = "date";
        public static final String SHOW_TIME_STAMP = "showTimeStamp";
        public static final String TYPE = "type";
    }

    public static interface MessageType
    {

        public static final int OUTGOING = 0;
        public static final int INCOMING = 1;
        public static final int PRESENCE_AVAILABLE = 2;
        public static final int PRESENCE_AWAY = 3;
        public static final int PRESENCE_DND = 4;
        public static final int PRESENCE_UNAVAILABLE = 5;
        public static final int CONVERT_TO_GROUPCHAT = 6;
        public static final int STATUS = 7;
    }

    public static final class BlockedList
        implements BaseColumns, BlockedListColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "nickname ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "nickname ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/blockedList");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-blockedList";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-blockedList";
        public static final String DEFAULT_SORT_ORDER = "nickname ASC";
        public static final String PROVIDER_NAME = "provider_name";
        public static final String ACCOUNT_NAME = "account_name";


        private BlockedList()
        {
        }
    }

    public static interface BlockedListColumns
    {

        public static final String USERNAME = "username";
        public static final String NICKNAME = "nickname";
        public static final String PROVIDER = "provider";
        public static final String ACCOUNT = "account";
    }

    public static final class ContactList
        implements BaseColumns, ContactListColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "name ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "name ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/contactLists");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-contactLists";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-contactLists";
        public static final String DEFAULT_SORT_ORDER = "name ASC";
        public static final String PROVIDER_NAME = "provider_name";
        public static final String ACCOUNT_NAME = "account_name";


        private ContactList()
        {
        }
    }

    public static interface ContactListColumns
    {

        public static final String NAME = "name";
        public static final String PROVIDER = "provider";
        public static final String ACCOUNT = "account";
    }

    public static final class Contacts
        implements BaseColumns, ContactsColumns, PresenceColumns, ChatsColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC");
        }

        public static final Cursor queryChatContacts(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI_CHAT_CONTACTS, projection, where, null, orderBy != null ? orderBy : "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC");
        }

        public static final Cursor queryContactsBy(ContentResolver cr, String projection[], long providerId, long accountId, String where, String orderBy)
        {
            android.net.Uri.Builder builder = CONTENT_URI_CONTACTS_BY.buildUpon();
            ContentUris.appendId(builder, providerId);
            ContentUris.appendId(builder, accountId);
            Uri uri = builder.build();
            return cr.query(uri, projection, where, null, orderBy != null ? orderBy : "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC");
        }

        public static final Cursor queryChatContactsBy(ContentResolver cr, String projection[], long providerId, long accountId, String where, String orderBy)
        {
            android.net.Uri.Builder builder = CONTENT_URI_CHAT_CONTACTS.buildUpon();
            ContentUris.appendId(builder, providerId);
            ContentUris.appendId(builder, accountId);
            Uri uri = builder.build();
            return cr.query(uri, projection, where, null, orderBy != null ? orderBy : "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC");
        }

        public static final Cursor queryOnlineContactsBy(ContentResolver cr, String projection[], long providerId, long accountId, String where, String orderBy)
        {
            android.net.Uri.Builder builder = CONTENT_URI_ONLINE_CONTACTS_BY.buildUpon();
            ContentUris.appendId(builder, providerId);
            ContentUris.appendId(builder, accountId);
            Uri uri = builder.build();
            return cr.query(uri, projection, where, null, orderBy != null ? orderBy : "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC");
        }

        public static final Cursor queryOfflineContactsBy(ContentResolver cr, String projection[], long providerId, long accountId, String where, String orderBy)
        {
            android.net.Uri.Builder builder = CONTENT_URI_OFFLINE_CONTACTS_BY.buildUpon();
            ContentUris.appendId(builder, providerId);
            ContentUris.appendId(builder, accountId);
            Uri uri = builder.build();
            return cr.query(uri, projection, where, null, orderBy != null ? orderBy : "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/contacts");
        public static final Uri CONTENT_URI_CHAT_CONTACTS = Uri.parse("content://im/contacts/chatting");
        public static final Uri CONTENT_URI_CONTACTS_BY = Uri.parse("content://im/contacts");
        public static final Uri CONTENT_URI_CHAT_CONTACTS_BY = Uri.parse("content://im/contacts/chatting");
        public static final Uri CONTENT_URI_ONLINE_CONTACTS_BY = Uri.parse("content://im/contacts/online");
        public static final Uri CONTENT_URI_OFFLINE_CONTACTS_BY = Uri.parse("content://im/contacts/offline");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-contacts";
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-contacts";
        public static final String DEFAULT_SORT_ORDER = "last_message_date DESC, mode DESC, nickname COLLATE UNICODE ASC";
        public static final String CHATS_CONTACT = "chats_contact";
        public static final String AVATAR_CONTACT = "avatar_contact";
        public static final String AVATAR_PROVIDER = "avatar_provider";
        public static final String AVATAR_ACCOUNT = "avatar_account";


        private Contacts()
        {
        }
    }

    public static interface ContactsColumns
    {

        public static final String USERNAME = "username";
        public static final String NICKNAME = "nickname";
        public static final String PROVIDER = "provider";
        public static final String ACCOUNT = "account";
        public static final String CONTACTLIST = "contactList";
        public static final String TYPE = "type";
        public static final int TYPE_NORMAL = 0;
        public static final int TYPE_TEMPORARY = 1;
        public static final int TYPE_GROUP = 2;
        public static final int TYPE_BLOCKED = 3;
        public static final String SUBSCRIPTION_STATUS = "subscriptionStatus";
        public static final int SUBSCRIPTION_STATUS_NONE = 0;
        public static final int SUBSCRIPTION_STATUS_SUBSCRIBE_PENDING = 1;
        public static final int SUBSCRIPTION_STATUS_UNSUBSCRIBE_PENDING = 2;
        public static final String SUBSCRIPTION_TYPE = "subscriptionType";
        public static final int SUBSCRIPTION_TYPE_NONE = 0;
        public static final int SUBSCRIPTION_TYPE_TO = 1;
        public static final int SUBSCRIPTION_TYPE_FROM = 2;
        public static final int SUBSCRIPTION_TYPE_BOTH = 3;
        public static final int SUBSCRIPTION_TYPE_REMOVE = 4;
    }

    public static final class Account
        implements BaseColumns, AccountColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "name ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "name ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/accounts");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-accounts";
        public static final String DEFAULT_SORT_ORDER = "name ASC";


        private Account()
        {
        }
    }

    public static interface AccountColumns
    {

        public static final String NAME = "name";
        public static final String PROVIDER = "provider";
        public static final String USERNAME = "username";
        public static final String PASSWORD = "pw";
        public static final String ACTIVE = "active";
        public static final String KEEP_SIGNED_IN = "keep_signed_in";
    }

    public static final class Provider
        implements BaseColumns, ProviderColumns
    {

        public static final Cursor query(ContentResolver cr, String projection[])
        {
            return cr.query(CONTENT_URI, projection, null, null, "name ASC");
        }

        public static final Cursor query(ContentResolver cr, String projection[], String where, String orderBy)
        {
            return cr.query(CONTENT_URI, projection, where, null, orderBy != null ? orderBy : "name ASC");
        }

        public static final Uri CONTENT_URI = Uri.parse("content://im/providers");
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-providers";
        public static final String DEFAULT_SORT_ORDER = "name ASC";


        private Provider()
        {
        }
    }

    public static interface ProviderColumns
    {

        public static final String NAME = "name";
        public static final String FULLNAME = "fullname";
    }


    private Im()
    {
    }
}